<?php

namespace PlatBundle\Controller;

use ApiBundle\Controller\BaseController;

class AuthController extends BaseController
{
    /*
     * 首页
     */
    public function indexAction()
    {
        if(!$this->get("session")->get("plat_id")){

            return $this->render('PlatBundle:Auth:login.html.twig');
        }

        $conn = $this->get("database_connection");
        $data['company_count'] = $conn->fetchColumn("SELECT count(*) FROM company WHERE 1");

        $data['district_count'] = $conn->fetchColumn("SELECT count(*) FROM district WHERE 1");

        $data['super_admin_count'] = $conn->fetchColumn("SELECT count(*) FROM admin WHERE admin_role_id = 2");

        $data['teac_admin_count'] = $conn->fetchColumn("SELECT count(*) FROM admin WHERE admin_role_id = 4");

        $data['new_company'] = $conn->fetchAll("SELECT name, DATE_FORMAT(created_at,'%Y.%m.%d') as created_time, id FROM company WHERE 1 ORDER BY created_at DESC LIMIT 10");

        return $this->render("PlatBundle::homepage.html.twig",$data);

    }


    /*
     * 登录
     */
    public function loginAction()
    {

        return $this->render("PlatBundle:Auth:login.html.twig");

    }

    /*
     * 找回密码
     */
    public function forgetPasswordAction()
    {

        return $this->render("PlatBundle:Auth:forgetPassword.html.twig");

    }
}
